package g4p.tests;

import processing.core.PApplet;

public class MouseTest extends PApplet{

		private final int W = 400;
		private final int H = 300;
		private final int LAST = W - 1;
		
		private boolean mevents[][];
		
		public void setup(){
			size(W,H);
			
			mevents = new boolean[W][7];
			
		}
		
		public void mousePressed(){
			mevents[LAST][0] = true;
		}
		
		public void mouseReleased(){
			mevents[LAST][1] = true;
		}
		
		public void mouseClicked(){
			mevents[LAST][2] = true;
		}
		
		public void mouseMoved(){
			mevents[LAST][3] = true;
		}
		
		public void mouseDragged(){
			mevents[LAST][4] = true;
		}
		
		public void mouseEntered(){
			mevents[LAST][5] = true;
		}
		
		public void mouseExited(){
			mevents[LAST][6] = true;
		}
		
		public void shuffleUp(){
			for(int i = 0; i < W - 1; i++)
				for(int j = 0; j < 7; j++)
					mevents[i][j] = mevents[i+1][j];
			
			for(int j = 0; j < 7; j++)
				mevents[LAST][j] = false;
		}
		
		public void draw(){
			background(0);
			stroke(255);
			strokeWeight(1);
			for(int i = 0; i < W - 1; i++){
				for(int j = 0; j < 7; j++){
					if(mevents[i][j])
						line(i,j*10,i,j*10+10);
				}
			}
			shuffleUp();
		}
}
